<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
		<script type="text/javascript">
			function convert_long() {
				
				// 获取输入的长度
				var lengthValue = document.getElementById("length").value;
				
				// 获取从什么单位
				var $from = document.getElementById("from");
				var fromIndex = $from.selectedIndex;
				var fromValue = $from.options[fromIndex].value;
				if (fromValue == '微摩尔(μmol)') {
					lengthValue = lengthValue;
				} else if (fromValue == '毫摩尔(mmol)') {
					lengthValue *= (1000*1000);
				} else if (fromValue == '摩尔(mol)') {
					lengthValue *= (1000*1000*10);
				} 
				// 获取到什么单位
				var $to = document.getElementById("to");
				var toIndex = $to.selectedIndex;
				var toValue = $to.options[toIndex].value;
				
				var target = 0;
				if (toValue == '微摩尔(μmol)') {
					target = lengthValue;
				} else if (toValue == '毫摩尔(mmol)') {
					target = lengthValue / (1000*1000);
				} else if (toValue == '摩尔(mol)') {
					target = lengthValue /(1000*1000*10);
				} 
				
				document.getElementById('result').value = target;
				
			}
		</script>
		<style>
			html{
				background-color: rgb(80,44,108);
			}
			div{
				background-color: rgb(80,44,108);
				opacity: 0.9;
			}
			#a{
				font-size: 30px;
				margin-bottom: 5px;
				padding: 10px;
			}
			#d{
				padding: 10px;
			}
			#b{
				padding: 2%;
			}
			#db{
				margin-left: 20px;
			}
			.tx{
				font-size: 20px;
				padding: 10px;
			}
		</style>
	</head>
	<body>
		<div id="a" class="tx" align="center">
			物质的量的换算
		</div>
		
		<div id="b" align="center">
			<font id="ba" class="tx">物质的量：</font><input type="text" id="length">
			<font id="bb" class="tx">从：</font><select id="from">
					<option>微摩尔(μmol)</option>
					<option>毫摩尔(mmol)</option>
					<option>摩尔(mol)</option>
			</select>
		</div>
	   <div id="c" align="center">
		<font id="ca" class="tx">结果：</font>
		<input type="text" disabled="disabled" id="result">	
		<font id="cb" class="tx">到：</font><select id="to">
				<option>微摩尔(μmol)</option>
				<option>毫摩尔(mmol)</option>
				<option>摩尔(mol)</option>
			</select>
		</div>
		
		<div id="d" align="center">
				<button type="button" onclick="return convert_long()"  id="da">转换</button>
				<a href="../../../index.html"><button type="button"  id="db">返回</button></a>
			</div>	
	</body>
</html>

